package com.shouxin.attendance.serialport;

import com.shouxin.attendance.constants.CommonConstants;

/**
 * 报警器命令参数
 * Created by ligang on 16/7/19.
 */
public enum AlarmCMD {

	ALARM1(CommonConstants.PORT_1, "A5A5A5A10000A1", "A5A5A5A10001A0"),
	ALARM2(CommonConstants.PORT_2, "A5A5A5A20000A2", "A5A5A5A20001A3"),
	ALARM3(CommonConstants.PORT_3, "A5A5A5A30000A3", "A5A5A5A30001A2"),
	ALARM4(CommonConstants.PORT_4, "A5A5A5A40000A4", "A5A5A5A40001A5");

	private String port;

	private String open;

	private String close;

	AlarmCMD(String port, String open, String close) {
		this.port = port;
		this.open = open;
		this.close = close;
	}

	public static String getOpenCmd(String port) {
		for (AlarmCMD cmd : values()) {
			if (cmd.port.equalsIgnoreCase(port)) {
				return cmd.open;
			}
		}
		return "";
	}

	public static String getCloseCmd(String port) {
		for (AlarmCMD params : values()) {
			if (params.port.equalsIgnoreCase(port)) {
				return params.close;
			}
		}
		return "";
	}
}
